﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using EM.Components.Entities;

namespace EM.Components.DataAccess
{
    public class LeadsDataAccess:BaseDataAccess,IEntityDataService<EM_Leads>
    {
        public LeadsDataAccess():base() 
        {
        }

        #region interface inplementation
        public List<EM_Leads> GetAll()
        {
            throw new NotImplementedException();
        }

        public EM_Leads Get(int entityId)
        {
            throw new NotImplementedException();
        }

        public EM_Leads Update(EM_Leads entity)
        {
            throw new NotImplementedException();
        }

        public EM_Leads Add(EM_Leads entity)
        {
            ValidateNull<EM_Leads>(entity);
            entity.LeadID = 0;
            base.Ctx.EM_Leads.AddObject(entity);
            base.Ctx.SaveChanges();

            var lead = (from l in base.Ctx.EM_Leads
                        where l.EmailAddress == entity.EmailAddress
                        select l).First<EM_Leads>();
            return lead;
        }

        public void Delete(EM_Leads entity)
        {
            throw new NotImplementedException();
        }

        public void Delete(int entityId)
        {
            throw new NotImplementedException();
        }
        #endregion
    }
}
